export function connect(mapStateToProps, mapDispatchToProps) {
  return function(Component) {
    class Connect extends React.Component {
      componentDidMount() {
        this.context.store.subscribe(this.handleStoreChange.bind(this));
      }
      handleStoreChange() {
        this.forceUpdate();
      }
      render() {
        return (
          <Component
            {...this.props}
            {...mapStateToProps(this.context.store.getState())}
            {...mapDispatchToProps(this.context.store.dispatch)}
          />
        );
      }
    }
    Connect.contextType = {
      store: PropTypes.object,
    };
    return Connect;
  };
}
